package uk.co.lukeparker;

import java.util.ArrayList;

import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

import uk.co.lukeparker.listeners.PlayerListener;

public class JazzCraft extends JavaPlugin {
	
	public PlayerListener playerListener = new PlayerListener(this);
	
	public static ArrayList<String> team1 = new ArrayList<String>();
	public static ArrayList<String> team2 = new ArrayList<String>();
	
	@Override
	public void onEnable(){
		PluginManager pm = getServer().getPluginManager();
		
		pm.registerEvents(playerListener, this);
		
		//getCommand("command").setExecutor(new JazzCommandExecutor(this));
		getCommand("setlobbyspawn").setExecutor(new JazzCommandExecutor(this));
		getCommand("setteam1spawn").setExecutor(new JazzCommandExecutor(this));
		getCommand("setteam2spawn").setExecutor(new JazzCommandExecutor(this));
		getCommand("join").setExecutor(new JazzCommandExecutor(this));
		getCommand("leave").setExecutor(new JazzCommandExecutor(this));
		
		FileConfiguration config = getConfig();
		
		config.addDefault("Team Names.1", "team1");
		config.addDefault("Team Names.2", "team2");
		
		config.addDefault("Lobby Spawn.world", "world");
		config.addDefault("Lobby Spawn.x", 0);
		config.addDefault("Lobby Spawn.y", 0);
		config.addDefault("Lobby Spawn.z", 0);
		
		config.addDefault("Team1 Spawn.world", "world");
		config.addDefault("Team1 Spawn.x", 0);
		config.addDefault("Team1 Spawn.y", 0);
		config.addDefault("Team1 Spawn.z", 0);
		
		config.addDefault("Team2 Spawn.world", "world");
		config.addDefault("Team2 Spawn.x", 0);
		config.addDefault("Team2 Spawn.y", 0);
		config.addDefault("Team2 Spawn.z", 0);
		
		config.options().copyDefaults(true);
		
		saveConfig();
	}
	
	public static String messageTemplate(String message, ChatColor color){
		return ChatColor.YELLOW + "[JazzCraft]" + color + " " + message;
	}
}
